package org.jeecg.modules.demo.zyExam.zyexamaddpaper.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import org.jeecg.modules.demo.zyExam.zyexamaddpaper.entity.ZyExamAddPaper;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Description: 出卷
 * @Author: jeecg-boot
 * @Date:   2024-01-07
 * @Version: V1.0
 */
@Repository
public interface ZyExamAddPaperMapper extends BaseMapper<ZyExamAddPaper> {


//    @Select("SELECT * FROM zy_exam_add_paper WHERE source LIKE CONCAT('%', #{subject}, '%')")
    @Select("SELECT * FROM zy_exam_add_paper WHERE source LIKE CONCAT('%', COALESCE (#{subject},source), '%')")
    List<ZyExamAddPaper> queryBySubject(@Param("subject") String subject);

    @Select("SELECT item_text from  sys_dict_item where item_value = #{source}")
    String querySource(String source_code);


    @Select("SELECT paper_name,id FROM zy_exam_add_paper ")
    List<Map<String,String>> getAllPaper();


    @Select("SELECT DISTINCT paper_name FROM zy_exam_add_paper ")
    List<String> getDistinctPaperNames();

    @Select("SELECT paper_name, id FROM zy_exam_add_paper WHERE  paper_name = #{paperName}")
    List<Map<String, String>> getIdsForPaperName(@Param("paperName") String paperName);


    @Delete("DELETE FROM zy_exam_add_paper WHERE paper_code = #{id}")
    void deleteByPaperCode(String id);

     @Select("SELECT paper_name FROM zy_exam_add_paper WHERE id = #{paperId}")
    String queryPaperName(String paperId);

     @Select("SELECT score_pass FROM zy_exam_add_paper WHERE id = #{paperId}")
    String querySourcePass(String paperId);
}
